package com.yunfei.commonbase.map;


import java.util.HashMap;

public class Map<K,T> extends HashMap<K,T> {
    public String getString(String key){
        try {
            return this.get(key).toString();
        }catch (Exception e){
            throw new RuntimeException(this.get(key)+"转换成String类型错误");
        }

    }

    public int getInt(String key){
        try {
            return Integer.parseInt(this.get(key).toString());
        }catch (Exception e){
            throw new RuntimeException(this.get(key)+"转换成int类型错误");
        }

    }

    public short getShort(String key){
        try {
            return Short.parseShort(this.get(key).toString());
        }catch (Exception e){
            throw new RuntimeException(this.get(key)+"转换成short类型错误");
        }

    }

    public byte getByte(String key){
        try {
            return Byte.parseByte(this.get(key).toString());
        }catch (Exception e){
            throw new RuntimeException(this.get(key)+"转换成byte类型错误");
        }

    }

    public long getLong(String key){
        try {
            return Long.parseLong(this.get(key).toString());
        }catch (Exception e){
            throw new RuntimeException(this.get(key)+"转换成long类型错误");
        }
    }

    public double getDouble(String key){
        try {
            return Double.parseDouble(this.get(key).toString());
        }catch (Exception e){
            throw new RuntimeException(this.get(key)+"转换成double类型错误");
        }
    }

    public float getFloat(String key){
        try {
            return Float.parseFloat(this.get(key).toString());
        }catch (Exception e){
            throw new RuntimeException(this.get(key)+"转换成float类型错误");
        }

    }

    public char[] getChar(String key){
        try {
            return this.get(key).toString().toCharArray();
        }catch (Exception e){
            throw new RuntimeException(this.get(key)+"转换成char[]类型错误");
        }
    }
}
